import { Controller, Get, Post, Body, Patch, Param, Delete } from '@nestjs/common';
import { UserService } from './user.service';
import { CreateUserDto } from './dto/create-user.dto';
import { UpdateUserDto } from './dto/update-user.dto';
import { QueryUserPageDto } from './dto/query-user-page.dto';

import { ApiTags, ApiBearerAuth, ApiOperation } from '@nestjs/swagger';


@ApiTags('用户管理')
@ApiBearerAuth()
@Controller('user')
export class UserController {
  constructor(private readonly userService: UserService) {}
  // 创建用户
  @Post('/create')
  @ApiOperation({ summary: '创建用户' })
  create(@Body() createUserDto: CreateUserDto) {
    return this.userService.create(createUserDto);
  }

  // 查询所有用户
  @Get('/listAll')
  @ApiOperation({ summary: '查询所有用户' })
  findAll() {
    return this.userService.findAll();
  }

  // 分页查询用户列表
  @Post('/list')
  @ApiOperation({ summary: '分页查询用户列表' })
  findList(@Body() query: QueryUserPageDto) {
    return this.userService.findList(query);
  }

  // 查询单个用户
  @Get('/get/:id')
  @ApiOperation({ summary: '查询单个用户' })
  findOne(@Param('id') id: string) {
    return this.userService.findOne(+id);
  }

  // 更新用户信息
  @Post('/update')
  @ApiOperation({ summary: '更新用户信息' })
  update(@Body() updateUserDto: UpdateUserDto) {
    return this.userService.update(updateUserDto);
  }

  // 删除用户
  @Get('/remove/:id')
  @ApiOperation({ summary: '删除用户' })
  remove(@Param('id') id: string) {
    return this.userService.remove(+id);
  }
}
